package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.Autofill;
import com.sky.dto.EmployeeDTO;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Category;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from sky_take_out.employee where username = #{username}")//employee
    Employee getByUsername(String username);

    @Insert("insert into sky_take_out.employee" +
            "(name,username,password,phone,sex, id_number,create_time,update_time,create_user,update_user,status)"+
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    @Autofill(value = OperationType.INSERT)
    void add(Employee employee);
    //分页查询
//@Select("select * from sky_take_out.employee limit 0,10")
Page<Employee> selects(EmployeePageQueryDTO employeePageQueryDTO);

//启用禁用员工账号
    //@Update("update sky_take_out.employee set   status = 0 where id=#{id}")
@Autofill(value = OperationType.UPDATE)
    public void statorstop( Employee employee);

@Select("select * from sky_take_out.employee where id=#{id}")
    Employee getById(Long id);

    /**
     * 根据类型查询分类
     * @param type
     * @return
     */
    List<Category> list(Integer type);

}
